package com.gf.demo.rabbitmqdemo.config;

import com.gf.framework.common.utils.list.GfArrayList;
import com.gf.framework.rabbitmq.model.*;
import com.gf.framework.rabbitmq.porperties.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author gaofei
 * @date 2022/6/12 13:57
 */
@Configuration
@Component
public class MqConfig {
    @Bean
    MqProperties mqProperties() {
        return new MqProperties() {
            @Override
            public List<ExchangeInfo> getExchanges() {
                return new GfArrayList<ExchangeInfo>().of(new ExchangeInfo("test1", ExchangeType.DIRECT));

            }

            @Override
            public List<QueueInfo> getQueues() {
                QueueInfo queueInfo = QueueInfo.builder().name("test1.queue").
                        bindingInfos(
                                new GfArrayList<BindingInfo>().of(new BindingInfo("test1", "111"))).
                        durable(false).
                        build();

                return new GfArrayList<QueueInfo>().of(queueInfo);
            }
        };
    }
}
